<template>
  <el-dialog v-model="updateDialog" title="修改" width="800">
    <el-form>
      <el-row>
        <el-col :span="12">
          <el-form-item label="工号" label-width="80">
            <el-input readonly autocomplete="off" v-model="formData.staffNo"/>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="真实姓名" label-width="80">
            <el-input autocomplete="off" v-model="formData.realName"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="密码" label-width="80">
            <el-input autocomplete="off" v-model="formData.password"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别" label-width="80">
            <el-select autocomplete="off" v-model="formData.gender" placeholder="请选择你的性别">
              <el-option label="男" :value="1"/>
              <el-option label="女" :value="0"/>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="身份证号" label-width="80">
            <el-input autocomplete="off" v-model="formData.idCard"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号码" label-width="80">
            <el-input autocomplete="off" v-model="formData.phone"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="出生日期" label-width="80">
            <el-date-picker
                autocomplete="off"
                v-model="formData.dateOfBirth"
                type="date" placeholder="选择日期"
                :editable="false"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                style="width: 100%;"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="组织ID" label-width="80">
            <el-input autocomplete="off" v-model="formData.organizationId"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="岗位名称" label-width="80">
            <el-input autocomplete="off" v-model="formData.jobName"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="薪资" label-width="80">
            <el-input autocomplete="off" v-model="formData.salary"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="updateDialog = false">关闭</el-button>
        <el-button @click="save" type="primary">保存</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import {defineModel} from "@vue/runtime-core";
import axios from '../../axios/index.js'
import {ElMessage} from "element-plus";

let updateDialog = defineModel('updateDialog')

let formData = defineModel('rowData');
let nan = 1
let nv = 0
//保存用户
function save() {
  console.log(formData)
  formData.value.status = formData.value.status ? 1 : 0
  axios.put('/staff', null, {params: formData.value}).then(resp => {
    ElMessage({
      message: resp.data.message,
      type: 'success',
      duration: 1500
    })
    updateDialog.value = false
  })
}

console.log(formData)
</script>

<style scoped>

</style>
